package com.lestar.www.wuliancamtest.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.Image;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;

import com.lestar.www.wuliancamtest.R;
import com.lestar.www.wuliancamtest.WulianCam.CamUtils;
import com.lestar.www.wuliancamtest.WulianCam.WulianCamManager;

/**
 * User: EEE
 * Date: 2016/8/3
 * Time: 15:34
 */
public class BarcodeSettingActivity extends Activity {
    private static final String TAG = "BarcodeSettingActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_barcode_setting);

        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        windowManager.getDefaultDisplay().getMetrics(metrics);
        final int qrWidth =  metrics.widthPixels - CamUtils.px2dip(this, 45 * 2); // 45 for padding

        final String wifiInfo = WulianCamManager.getInstance(this).getQRData();
        Bitmap qrBitmap = CamUtils.createQRImage(wifiInfo, qrWidth, qrWidth);
        ImageView qrIv = (ImageView) findViewById(R.id.barcode_iv);
        qrIv.setImageBitmap(qrBitmap);

        Button confirmBtn = (Button) findViewById(R.id.hear_voice_btn);
        confirmBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "onClick: confirm btn");
                // TODO:
            }
        });
    }
}
